import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [NaiveUiResolver()]
    }),
  ],
  server: {
    host: true,
    proxy: {
      '/es': {
        target: 'http://127.0.0.1:9200',
        secure: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/es/, ''),
      }
    }
  },
  build: {
    outDir: './dist',
    sourcemap: false,
    chunkSizeWarningLimit: 1536,
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return id.toString().split('node_modules/')[1].split('/')[0].toString();
          }
        }
      }
    }
  }
})
